local mhr      = require("meet_your_mods.mhr")
local status   = require("meet_your_mods.status")
local shortcut = require("meet_your_mods.shortcut")
local routine  = require("meet_your_mods.routine_framework")
local setting  = require("meet_your_mods.setting")
local ui       = require("meet_your_mods.ui")

local components = {
    require("meet_your_mods.components.no_random"),
    require("meet_your_mods.components.quest"),
    require("meet_your_mods.components.berserker"),
    require("meet_your_mods.components.spider_man"),
    require("meet_your_mods.components.myset"),
    require("meet_your_mods.components.escape_master"),
    require("meet_your_mods.components.damage_text"),
    require("meet_your_mods.components.dangoist"),
    require("meet_your_mods.components.miscellaneous"),
    require("meet_your_mods.components.facility"),
    require("meet_your_mods.components.equipment"),
    require("meet_your_mods.components.talisman"),
    require("meet_your_mods.components.inventory"),
    require("meet_your_mods.components.debug"),
    nil,
}

mhr:initialize()
setting:initialize("meet_your_mods.setting")
status:initialize()
shortcut:initialize()
routine:initialize()
for _, component in pairs(components) do
    if component then
        component:initialize()
    end
end

setting:load_setting()
for _, component in pairs(components) do
    if component then
        component:normalize()
    end
end

re.on_script_reset(function()
    setting:save_setting()
    mhr:release()
end)

re.on_application_entry("FinalizeGameCore", function()
    setting:save_setting()
    mhr:release()
end)

ui:start()
